<template>
  <header>
    <a class="navbar-brand" href="#">
      <img src="./img/logo.svg" width="50" height="50" />
      <h1>Chatriq</h1>
    </a>
    <div class="nav">
      <!-- 显示搜索框 -->
      <span @click="kai = !kai" class="iconfont icon-sousuo-"></span>
      <span class="iconfont icon-bijiben"></span>
      <span class="iconfont icon-zuanshi"></span>
      <span class="iconfont icon-lingsheng"></span>
      <span class="iconfont icon-shenglve"></span>
      <!-- 搜索框 -->
      <div class="sou" v-show="kai">
        <form>
          <input
            type="text"
            class="form-control"
            placeholder="Search here..."
            autofocus=""
          />
          <button class="search-submit" type="submit">
            <i class="iconfont icon-sousuo-"></i>
          </button>
          <a @click="kai = !kai" href="#" class="search-close">
            <i
              style="display: table-cell; vertical-align: middle;"
              class="iconfont icon-jian"
            ></i>
          </a>
        </form>
      </div>
      <div class="tu">
        <div class="tou"></div>
      </div>
    </div>
  </header>
</template>

<script>
export default {
  data() {
    return {
      kai: false,
    }
  },
}
</script>

<style lang="scss" scoped>
.sou {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0 1rem;
  box-sizing: border-box;
  z-index: 10;
  transition: all 0.2s ease-in-out;
  opacity: 1;
  visibility: visible;
}
.form-control {
  position: absolute;
  left: 0;
  top: 0;
  border: 0;
  padding: 0 3.375rem 0 3.125rem;
  height: 100%;
  width: 100%;
  outline: 0;
  box-sizing: border-box;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  display: block;
}
.search-submit {
  position: absolute;
  right: 0.625rem;
  top: 0.875rem;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 2.8125rem;
  height: 2.8125rem;
  border-radius: 6.25rem;
}
.search-close {
  position: absolute;
  top: 0;
  left: 0;
  width: 3.125rem;
  height: 100%;
  text-align: center;
  display: table;
  text-decoration: none;
}
header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  padding: 0.5rem 1rem;
  background: #fff;
  z-index: 1030;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
  .navbar-brand {
    display: inline-block;
    padding-top: 0.2125rem;
    padding-bottom: 0.2125rem;
    margin-right: 1rem;
    font-size: 1.25rem;
    line-height: inherit;
    white-space: nowrap;
    img {
      float: left;
    }
    h1 {
      font-weight: 500;
      margin-left: 10px;
      margin-top: 12px;
      font-size: 24px;
      display: inline-block;
      line-height: 1.2;
      color: #000;
    }
  }
  .nav {
    width: 250px;
    height: 56px;
    line-height: 56px;
    float: right;
    span {
      //   margin-top: 10px;
      display: inline-block;
      width: 36px;
      height: 36px;
      line-height: 36px;
      text-align: center;
      border-radius: 6.25rem;
      transition: all 0.2s ease-in;
      color: #949aa2;
      &:hover {
        background: #eee;
      }
    }
    .tu {
      float: right;
      .tou {
        background-position: -5px -5px;
        background-image: url('./img/spritesheet.png');
        background-repeat: no-repeat;
        display: block;
        width: 3.125rem;
        height: 3.125rem;
        border-radius: 6.25rem;
        margin-right: 1rem;
      }
    }
  }
}
</style>
